<?php
header("content-type:text/html;charset=utf-8");
include "../public/config/config.php";
include "../public/include/funcs.php";
$cfg_dbname = "wx";
$link=conn($cfg_dbhost,$cfg_dbuser,$cfg_dbpwd,$cfg_dbname,$cfg_dbchar);



function get_one($str){
	$arr_img = explode(";", $str);
	return $arr_img['0'];
}

$arr = select($link, "product","on_line = 1 order by rank desc limit 14 ");

$num = ceil(count($arr) / 2);

for($i=1; $i <= $num; $i++){
	$k = ($i - 1) * 2;
	$arr_list[$i-1]['id'] = $arr[$k]['id'];
	$arr_list[$i-1]['pimg'] = $domain."/files/upload/".get_one($arr[$k]['pimg']);
	$arr_list[$i-1]['pname'] = $arr[$k]['pname'];
	$arr_list[$i-1]['description'] = $arr[$k]['description'];
	$arr_list[$i-1]['money'] = $arr[$k]['money'];
	$arr_list[$i-1]['out_of'] = $arr[$k]['out_of'];
	
	$arr_list[$i-1]['id2'] = $arr[$k+1]['id'];
	$arr_list[$i-1]['pimg2'] = $domain."/files/upload/".get_one($arr[$k+1]['pimg']);
	$arr_list[$i-1]['pname2'] = $arr[$k+1]['pname'];
	$arr_list[$i-1]['description2'] = $arr[$k+1]['description'];
	$arr_list[$i-1]['money2'] = $arr[$k+1]['money'];
	$arr_list[$i-1]['out_of2'] = $arr[$k+1]['out_of'];
}


//echo "<pre>";
//print_r($arr);
//print_r($arr_list);
//echo "</pre>";
?>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
	<title>分享商城 -- 康承贝健</title>
	
	<!-- Bootstrap -->
	<link href="/public/css/bootstrap.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="public/main.css"/>
	
	<!-- HTML5 shim 和 Respond.js 是为了让 IE8 支持 HTML5 元素和媒体查询（media queries）功能 -->
	<!-- 警告：通过 file:// 协议（就是直接将 html 页面拖拽到浏览器中）访问页面时 Respond.js 不起作用 -->
	<!--[if lt IE 9]>
	<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
	<![endif]-->
</head>
<body>

<div class="container-fluid" style="padding: 0;">
	<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
		<!-- Indicators -->
		<ol class="carousel-indicators">
			<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
			<li data-target="#carousel-example-generic" data-slide-to="1"></li>
			<li data-target="#carousel-example-generic" data-slide-to="2"></li>
			<li data-target="#carousel-example-generic" data-slide-to="3"></li>
		</ol>

		<!-- Wrapper for slides -->
		<div class="carousel-inner" role="listbox">
			<div class="item active">
				<img src="imgs/index/1.jpg" alt="...">
				<div class="carousel-caption">
					<!--介绍文字1-->
				</div>
			</div>
			<div class="item">
				<img src="imgs/index/2.jpg" alt="...">
				<div class="carousel-caption">
					<!--介绍文字2-->
				</div>
			</div>
			<div class="item">
				<img src="imgs/index/3.jpg" alt="...">
				<div class="carousel-caption">
					<!--介绍文字3-->
				</div>
			</div>
			<div class="item">
				<img src="imgs/index/4.jpg" alt="...">
				<div class="carousel-caption">
					<!--介绍文字4-->
				</div>
			</div>
			
		</div>

		<!-- Controls -->
		<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
			<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
			<span class="sr-only">Previous</span>
		</a>
		<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
			<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
			<span class="sr-only">Next</span>
		</a>
	</div>
</div>

<div class="container-fluid" style="margin: 8px;">
	<span>热销推荐</span>
	<div class="more">
		<a href="list.php">更多>></a>
	</div>
</div>

<div class="container-fluid" style="padding: 0 20px;">
	<div class="row">
		<div class="row-1">
			<a href="list.php?tid=1">
				<img class="img-rounded imgdiy" src="imgs/index/nav1.jpg"/>
			</a>
		</div>
		<div class="row-1">
			<a href="list.php?tid=5">
				<img class="img-rounded imgdiy" src="imgs/index/nav2.jpg"/>
			</a>
		</div>
		<div class="row-1">
			<a href="list.php?tid=6">
				<img class="img-rounded imgdiy" src="imgs/index/nav3.jpg"/>
			</a>
		</div>
	</div>
	<div class="row row-top">
		<div class="row-2">
			<a href="list.php?tid=4">
				<img class="img-rounded imgdiy2" src="imgs/index/nav4.jpg"/>
			</a>
		</div>
		<div class="row-2">
			<a href="list.php?tid=8">
				<img class="img-rounded imgdiy2" src="imgs/index/nav5.jpg"/>
			</a>
		</div>
	</div>
</div>

<div class="container rmtj">热卖推荐</div>

<div class="container-fluid bg-gs">
	
<?php
foreach($arr_list as $v){
	$id =  $v['id'];
	$id2 = $v['id2'];
?>
	<div class="row mar_b">
		<a href="goods.php?id=<?php echo $id;?>">
			<div class="gds-l">
				<img class="img-list" src="<?php echo $v['pimg']?>"/>
				<p class="g-title"><?php echo $v['pname']?></p>
				<p>
					<span class="span-l">￥<?php echo $v['money'];?></span>
					<span class="span-r">已售：<?php echo $v['out_of'];?></span>
				</p>
			</div>
		</a>
		<a href="goods.php?id=<?php echo $id2;?>">
			<div class="gds-r">
				<img class="img-list" src="<?php echo $v['pimg2']?>"/>
				<p class="g-title"><?php echo $v['pname2']?></p>
				<p>
					<span class="span-l">￥<?php echo $v['money2'];?></span>
					<span class="span-r">已售：<?php echo $v['out_of2'];?></span>
				</p>
			</div>
		</a>
	</div>
	
<?php
}
?>	
	
	
</div>




<?php include "template/footer.php";?>

<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery，所以必须放在前边) -->
<script type="text/javascript" src="/public/js/jquery-3.3.1.min.js"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
</body>
</html>